package com.songtech.server.task.Initializing;

import com.songtech.server.frame.utils.ConfUtils;
import org.springframework.beans.factory.InitializingBean;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Create By YINN on 2018/4/20 13:14
 * Description :
 */
public class ErrorConfManager {

    private final static int MAX_TIMES = Integer.valueOf(ConfUtils.get("error.max.times"));

    private final static int MIN_TIME_DIFFERENCE = Integer.valueOf(ConfUtils.get("error.min.timeDifference"));

    private final static int LOGARITHMS = Integer.valueOf(ConfUtils.get("error.logarithms"));

    private final static Map<Integer,Integer> errorConfManager  = new ConcurrentHashMap<>();


//    @Override
    public void initErrorConfManager() throws Exception {

        for (int i = 0;i<MAX_TIMES - 1;i++){

            int minitesDifference = (int) (Math.pow( LOGARITHMS, i) * MIN_TIME_DIFFERENCE);

            errorConfManager.put(i+1,minitesDifference);
        }

    }


    public static Integer getMinitesDifference(int key) {
        return errorConfManager.get(key);
    }
}
